package com.codeforces.contest.c34;

import java.util.Arrays;
import java.util.Scanner;

public class _34B {

	static Scanner scanner = new Scanner(System.in);
	static int n, m, earn;
	static int[] tv;

	public static void main(String[] args) {
		n = scanner.nextInt();
		m = scanner.nextInt();
		tv = new int[n];
		for (int i=0;i<n;++i) {
			tv[i] = scanner.nextInt();
		}
		Arrays.sort(tv);
		earn = 0;
		for (int i=0;i<m;++i) {
			if (tv[i] < 0) {
				earn -= tv[i];
			}
			else {
				break;
			}
		}
		System.out.println(earn);

	}

}
